<template>
  <div>
    <form @submit.prevent="">
      <label>姓名：</label>
      <input type="text" v-model="patient.uname"><br><br>

      <label>年龄：</label>
      <input type="number" v-model="patient.age"><br><br>

      <label>身高：</label>
      <input type="number" v-model="patient.height">(米)<br><br>

      <label>体重：</label>
      <input type="number" v-model="patient.weight">(公斤)<br><br>

      <label>病史：</label>
      <input type="text" v-model="patient.history"><br><br>

      <button @click="judgment">诊断</button>
    </form>
   
    <p v-show="flag">患者的诊断结果：{{healthy ?  (healthy>18.5 && healthy<24.9 ? '健康' : '不健康' ):''}}</p>
    
  </div>
</template>

<script>
export default {
  data () {
    return {
      flag:false,
      healthy:0,
      patient:{
        uname:'',
        age:'',
        height:'',
        weight:'',
        history:'',
      }
    }
  },
  methods: {
    judgment(){
      this.flag=!this.flag
      this.healthy=this.patient.weight/(this.patient.height*this.patient.height)
    },

  }
}
</script>